package ua.kpi_java_training.tyshchenko.module2.test;

import static junit.framework.Assert.*;
import org.junit.Before;
import org.junit.Test;
import ua.kpi_java_training.tyshchenko.module2.*;

/**
 * @author Vlad Tyshchenko
 * @version 1.0 19 June 2013
 */
public class ListCreatureTest {
    Habitat habitat;
    ListCreature victims;
    ListCreature predators;

    @Before
    public void setUp() {
        habitat = new Habitat(new StabInputAllData());
        victims = new ListCreature(new Victim(habitat), 5);
        predators = new ListCreature(new Predator(habitat), 15);
    }

    @Test
    public void testSize() {
        assertEquals("Size victims ", victims.size(), 5);
        assertEquals("Size predators ", predators.size(), 15);
    }

    @Test
    public void testGetCreature() {
        assertTrue("check member in list (true victim) ", victims.getCreature(1) instanceof Victim);
        assertTrue("check member in list (true predator)", predators.getCreature(1) instanceof Predator);
        assertFalse("check member in list (false victim)", victims.getCreature(1) instanceof Predator);
        assertFalse("check member in list (false predator)", predators.getCreature(1) instanceof Victim);
    }

    @Test
    public void testAdd() {
        victims.add(victims.getCreature(1));
        assertEquals("add victims ", victims.size(), 6);
    }

    @Test
    public void testRemove() {
        victims.remove(victims.getCreature(0));
        assertEquals("remove victims ", victims.size(), 4);
    }
}
